<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件的嵌套</title>
    <script src="../../js/vue.js"></script>
</head>

<body>
    <div id="app">
    </div>
    <script>
        Vue.config.productionTip = false

        // 定义student组件 (子组件)
        const student = {
            template: `
            <div>
                <h2>学生名称：{{name}}</h2>
                <h2>学生年纪{{age}}</h2>
            </div>
            `,
            data() {
                return {
                    name: "meo",
                    age: 18
                }
            }
        };
        // 定义school组件(父组件)
        const school = {
            name: 'atguigu',//vue的开发者工具中呈现的名字。一般第三方插件会用
            template: `
            <div class="school">
                <h2>学校名称：{{name}}</h2>
                <h2>学校地址：{{address}}</h2>
                <student></student>
            </div>
            `,
            data() {
                return {
                    name: "meo",
                    address: '上海'
                }
            },
            components: {
                student
            }
        };

        // 定义hello组件(和school同级)
        const hello = {
            template: `
            <div class="hello">
                <h2>{{msg}}</h2>
            </div>
            `,
            data() {
                return {
                    msg: "啊啦啦啦Hello组件"
                }
            }
        };
        //创建app组件
        const app = Vue.extend({
            template: `
                <div>
                    <school></school> 
                    <hello></hello> 
                </div>
            `,
            components: {
                school,
                hello
            }
        })
        const vm = new Vue({
            template: `
                <app></app>
            `,
            data() {
                return {}
            },
            // 局部注册
            components: {
                app
            }
        })
        vm.$mount("#app")
    </script>
</body>

</html>